package com.anguin.mylibrary.controller;

import com.anguin.mylibrary.entity.BookEntity;
import com.anguin.mylibrary.mapper.BookMapper;
import com.anguin.mylibrary.service.BookService;
import com.anguin.mylibrary.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("api/book")
public class BookController extends BaseController
{
    @Autowired
    private BookService bookService;
    @GetMapping("getBookList")
    public JsonResult<List<BookEntity>> getBookList()
    {
        List<BookEntity> bookList = bookService.getAllBookList();

        return new JsonResult<>(JsonResult.SUCCESS,bookList);
    }
    @PostMapping("getBookByName")
    public JsonResult<BookEntity>getBook(@RequestParam String query)
    {
        BookEntity book = bookService.getBookByName(query);
        return new JsonResult<>(JsonResult.SUCCESS,book);
    }
}
